package com.woniuxy.controller;

import com.sun.rowset.internal.CachedRowSetWriter;
import com.woniuxy.entity.dto.AddressManagementDTO;
import com.woniuxy.entity.dto.CarDTO;
import com.woniuxy.service.CarService;
import com.woniuxy.util.PageData;
import com.woniuxy.util.ResponseData;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/car")
public class CarController {
    @Resource
    private CarService carService;

    @PostMapping("/queryAllCar")
    public ResponseData<?> queryAllCar(@RequestBody PageData<CarDTO> pageData) {
        return carService.queryAllCar(pageData);
    }

    @PostMapping("/addDriverBtn")
    public ResponseData<?> addDriverBtn(@RequestBody CarDTO carDTO) {
        return carService.addCar(carDTO);
    }

    @PostMapping("/updateStatus")
    public ResponseData<?> updateStatus(@RequestBody CarDTO carDTO) {
        return carService.updateStatus(carDTO);
    }

    @PostMapping("/queryAllDriver")
    public ResponseData<?> queryAllDriver() {
        return carService.queryAllDriver();
    }

    @PostMapping("/saveUpdateDriver")
    public ResponseData<?> saveUpdateDriver(@RequestBody CarDTO carDTO) {
        return carService.updateDriver(carDTO);
    }

    @PostMapping("/unBindDriver")
    public ResponseData<?> unBindDriver(@RequestBody CarDTO carDTO) {
        return carService.unBindDriver(carDTO);
    }
}
